CREATE TABLE [dbo].[AddressFormatRef]
(
[AddressFormatKey] [uniqueidentifier] NOT NULL,
[AddressFormatDesc] [nvarchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Formula] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsHandModified] [bit] NOT NULL CONSTRAINT [DF_AddressFormatRef_IsHandModified] DEFAULT ((0)),
[UpdatedOn] [datetime] NOT NULL CONSTRAINT [DF_AddressFormatRef_UpdatedOn] DEFAULT (getdate()),
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[IsSystemDefault] [bit] NOT NULL CONSTRAINT [DF_AddressFormatRef_IsSystemDefault] DEFAULT ((0)),
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AddressFormatRef] ADD CONSTRAINT [PK_AddressFormatRef] PRIMARY KEY CLUSTERED ([AddressFormatKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AddressFormatRef] ADD CONSTRAINT [AK_AddressFormatRef_AddressFormatDesc] UNIQUE NONCLUSTERED ([AddressFormatDesc]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AddressFormatRef] ADD CONSTRAINT [FK_AddressFormatRef_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[AddressFormatRef] ADD CONSTRAINT [FK_AddressFormatRef_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO